package cn.cihon.stream.wordcount

import org.apache.spark.{SparkConf, SparkContext}

/**
  * Created by eeexiu on 16-12-14.
  */
object OfflineWordCount {

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("wordcount")
    //val conf = new SparkConf().setAppName("wordcount").setMaster("local[2]")
    val sc = new SparkContext(conf)
    //val textRDD = sc.textFile("/var/testreadlocal")
    val textRDD = sc.textFile("data/wordcount/myword")
    val lineRDD = textRDD.flatMap(s => s.split("  ")).map((_,1)).reduceByKey(_+_)
    //lineRDD.collect.foreach(f =>  println("*****"+f))
    lineRDD.saveAsTextFile("/var/testresultlocal")
    //println("========"+lineRDD.collect().size)
  }
}
